package com.bill99.rpc;

/**
 * @author sheng.zhang
 * 
 */
public final class RpcException extends RuntimeException {

	private static final long serialVersionUID = 1L;

	public static final int CONNECT_EXCEPTION = 1;

	public static final int UNKNOWN_EXCEPTION = 2;

	public static final int NETWORK_EXCEPTION = 3;

	public static final int TIMEOUT_EXCEPTION = 4;

	public static final int FORBIDDEN_EXCEPTION = 5;

	public static final int FAILOVER_EXCEPTION = 6;

	public static final int BIZ_EXCEPTION = 7;

	private int code; // RpcException不能有子类，异常类型用ErrorCode表示，以便保持兼容。

	public RpcException(int code) {
		super();
		this.code = code;
	}

	public RpcException(int code, String message) {
		this(code, message, null);
	}

	public RpcException(String message, Throwable cause) {
		this(UNKNOWN_EXCEPTION, message, cause);
	}

	public RpcException(int code, String message, Throwable cause) {
		super(message, cause);
		this.code = code;
	}

	public int getCode() {
		return code;
	}

}